$(document).ready(function () {
    ReSizeWindow();
});
$(window).resize(function () {
    ReSizeWindow();
});

//滚轮滚动
$(window).mousewheel(function (event, delta, deltaX, deltaY) {
    if ($('.main_menu').attr('menuopen') == 'false') {
        if ($('.main_warp').attr('animate') == 'false') {
            var current = $('.main_warp').attr('current');
            var index = $('.main_warp').attr('index');
            //下滚动滚轮 deltaY=-1 上滚动滚轮 deltaY=1
            if (deltaY == 1 && current > 0) current--;
            if (deltaY == -1 && current < index) current++;

            if ($('.main_warp').attr('current') != current) {
                $('.main_warp').attr('animate', 'true');
                $('.main_warp').attr('current', current);
                $('.main_warp>ul').css('top', -100 * current + "%");
            }
        }
    }
});
$(document).on('transitionend webkitTransitionEnd oTransitionEnd', '.main_warp', function () {
    $(this).attr('animate', 'false');
});

$(document).on('click', '.main_menu>div>span', function () {
    var open = $('.main_menu').attr('menuopen');
    if ($('.main_menu').attr('state') == 'false') {
        open = (open == 'false') ? 'true' : 'false';
        mdi_class = (open == 'true') ? 'mdi mdi-playlist-play' : 'mdi mdi-menu';
        menustate = (open == 'true') ? 'true' : 'false';
        $('.main_menu').attr('menuopen', open);
        $(this).attr('class', mdi_class);
        $('.audio_btn').attr('menustate',menustate);
        $('.main_menu').attr('state', 'true');
    }
});

$(document).on('transitionend webkitTransitionEnd oTransitionEnd', '.main_menu', function () {
    $(this).attr('state', 'false');
});


function ReSizeWindow() {
    $('body').css("width", innerWidth);
    $('body').css("height", innerHeight);

    if (innerWidth / innerHeight <= 1.77) {
        $('video').css("width", "auto");
        $('video').css("height", innerHeight + "px");
    } else {
        $('video').css("width", innerWidth + "px");
        $('video').css("height", "auto");
    }
}
$(document).on('click', '.audio_btn>span', function () {
    var volume_back = $('audio')[0];
    // alert(volume_back.volume);
    if (volume_back.volume == 0) {
        $('.audio_btn>span[position="btn_change"]').css("left","55px");
        $('.audio_btn>span[position="btn_state"]').css("left","69px");
        $('.audio_btn>span[position="btn_state"]').text("NO");
        volume_back.volume = 1;
        // alert(volume_back.volume);

    } else {
        volume_back.volume = 0;
        $('.audio_btn>span[position="btn_change"]').css("left","79px");
        $('.audio_btn>span[position="btn_state"]').css("left","55px");
        $('.audio_btn>span[position="btn_state"]').text("OFF");        
        // alert(volume_back.volume);
    }

});